function maxProfit(prices: number[]): number {
    let total:number = 0;
    for(let i=1;i<prices.length;i++){
        prices[i]>prices[i-1] && (total = total + prices[i]-prices[i-1]);
    }
    prices.reduce((total,p,i)=> p>prices[i-1]? total+p-prices[i-1]:total,0)
    return total;
};

function maxProfit(prices: number[]): number {
    return  prices.reduce((total,p,i)=> p>prices[i-1]? total+p-prices[i-1]:total,0)
};